﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NS_DBOP;

public partial class sysManage_News : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DataSet ds = new DBoperate().ExecuteQuery("select * from NewsType", 0, 0, "table1");
            foreach (DataRow dr in ds.Tables["table1"].Rows)
            {
                this.drpType.Items.Add(new ListItem(dr["Type"].ToString(), dr["NTID"].ToString()));
            }
            this.drpType.Items.Insert(0, "请选择类型");
        }
    }
    protected void Submit1_ServerClick(object sender, EventArgs e)
    {
        string title = this.txtTitle.Text;
        string content = this.HtmlEditor1_HtmlEditorContent.Value.ToString();
        int type = Convert.ToInt32(this.drpType.SelectedItem.Value);
        int remark = Convert.ToInt32(this.drpRemark.SelectedItem.Value);
        int  userid = Convert.ToInt32(new DBoperate().ExecuteScalar("select Employeeid from Employee where username='"+Session["UserName"]+"'"));
        string strSql = "insert into News values(" + type + ",'" + title + "','" + content + "'," + remark + "," + userid + ",default)";
        int result = new DBoperate().ExecuteUpdate(strSql);
        if (result > 0)
        {
            Response.Write("<script>alert('插入成功！');window.location.href='NewsInfo.aspx'</script>");
        }
        
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        this.txtTitle.Text = "";
        this.HtmlEditor1_HtmlEditorContent.Value = "";
    }
}
